<%--
 *  File:    AjaxResult.jsp
 *  @Author: tendyhu
 *  Date:    2009-10-10 ??05:55:06

 *  Copyright (C) 2000 - 2009 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ page import="com.oval.util.*" %>
<%
        Enumeration e=request.getAttributeNames(); 
		StringBuffer arrStr = new StringBuffer("");
		
					while(e.hasMoreElements()){
				    String attributeName=(String)e.nextElement(); 
					Object attributeValue=request.getAttribute(attributeName); 
					if(attributeValue == null){
						continue;
					}
					if(attributeValue.getClass().getName().equals("java.util.Vector")) {
						Vector arrVector = (Vector)attributeValue;
						if(0<arrVector.size()){
						  boolean isFirstKey = true;			
							for(int i=0;i<arrVector.size();i++){
								HashMap map = (HashMap)arrVector.get(i);
								Set temp = map.keySet();
								Iterator iter = temp.iterator();
								while(iter.hasNext()){
									if(isFirstKey){
										arrStr.append("\""+attributeName + "\":[{");
										isFirstKey = false;
									}
									String keyname = (String)iter.next();
									if(iter.hasNext()){
										arrStr.append("'"+keyname + "': '" + JspHelper.filterNull(map.get(keyname)) +"',");
									}else{
										arrStr.append("'"+keyname + "': '" + JspHelper.filterNull(map.get(keyname)) +"'}");
									}
								}
								if(i!=arrVector.size()-1){
									arrStr.append(",{");
								}
							}
							arrStr.append("]");
						}else{
							arrStr.append("\""+attributeName + "\":[]");
						}
						if(e.hasMoreElements()){
							arrStr.append(",");
						}
					}else if(attributeValue.getClass().getName().equals("java.util.HashMap")) {
						HashMap arrHashMap = (HashMap)attributeValue;
						boolean isFirstKey = true;
						Set temp = arrHashMap.keySet();
						Iterator iter = temp.iterator();
						while(iter.hasNext()){
							if(isFirstKey){
								arrStr.append("\""+attributeName + "\":{");
								isFirstKey = false;
							}
							String keyname = (String)iter.next();
							if(iter.hasNext()){
								arrStr.append("'"+keyname + "': '" + JspHelper.filterNull(arrHashMap.get(keyname)) +"',");
							}else{
								arrStr.append("'"+keyname + "': '" + JspHelper.filterNull(arrHashMap.get(keyname)) +"'}");
								if(e.hasMoreElements()){
									arrStr.append(",");
								}
							}
						}
					}else if(attributeValue.getClass().getName().equals("java.lang.String")) {
						String arrString = (String)attributeValue;
						arrStr.append("\""+attributeName + "\":\"" + arrString + "\"");
						if(e.hasMoreElements()){
							arrStr.append(",");
						}
					}else if(attributeValue.getClass().getName().equals("java.lang.Integer")) {
						Integer arrInteger = (Integer)attributeValue;
						arrStr.append("\""+attributeName + "\":\"" + arrInteger.intValue()+ "\"");
						if(e.hasMoreElements()){
							arrStr.append(",");
						}
					}else if(attributeValue.getClass().getName().equals("java.lang.Double")) {
						Double arrDouble = (Double)attributeValue;
						arrStr.append("\""+attributeName + "\":\"" + arrDouble.doubleValue()+ "\"");
						if(e.hasMoreElements()){
							arrStr.append(",");
						}
					}
				}
		out.print("{" + arrStr.toString() + "}");
%>	